import request from "@/utils/request";

export function getPermissionGroup(id) {
  return request({
    url: "/api/identity/permission-groups/" + id,
    method: "get",
  });
}

export function getPermissionGroups(paramters) {
  return request({
    url: "/api/identity/permission-groups",
    method: "get",
    params: paramters,
  });
}

export function addPermissionGroups(permissionGroups) {
  return request({
    url: "/api/identity/permission-groups",
    method: "post",
    data: permissionGroups,
  });
}

export function updatePermissionGroups(permissionGroups) {
  return request({
    url: "/api/identity/permission-groups",
    method: "put",
    data: permissionGroups,
  });
}

export function deletePermissionGroup(id) {
  return request({
    url: "/api/identity/permission-groups/" + id,
    method: "delete",
  });
}

export function getPermissionItem(id) {
  return request({
    url: "/api/identity/permission-groups/items/" + id,
    method: "get",
  });
}

export function addPermissionItem(permissionItem) {
  return request({
    url: "/api/identity/permission-groups/items",
    method: "post",
    data: permissionItem,
  });
}

export function updatePermissionItem(permissionItem) {
  return request({
    url: "/api/identity/permission-groups/items",
    method: "put",
    data: permissionItem,
  });
}

export function deletePermissionItem(id) {
  return request({
    url: "/api/identity/permission-groups/items/" + id,
    method: "delete",
  });
}

export function getPermissionItemApiGrants(id) {
  return request({
    url: "/api/identity/permission-groups/items/" + id + "/api-grants/",
    method: "get",
  });
}

export function updatePermissionItemApiGrants(itemId , datas) {
  return request({
    url: "/api/identity/permission-groups/items/" + itemId + "/api-grants/",
    method: "put",
    data: datas,
  });
}
